package com.dzzw.Servlet.DetailServlet;

import com.dzzw.Dao.DetailDao;
import com.dzzw.Model.Detail;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/View/SelectAllDetailByUIDServlet")
public class SelectAllDetailByUIDServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public SelectAllDetailByUIDServlet(){
        super();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        int user_id = Integer.parseInt(request.getParameter("user_id"));
        List<Detail> list = DetailDao.SelectAllDetailByUID(user_id);
        HttpSession session = request.getSession();
        session.setAttribute("SelectAllDetailByUID", list);
        request.getRequestDispatcher("/View/SelectAllDetailByUid.jsp").forward(request, response);
    }
}
